package Smallprogram.serlet;

import Smallprogram.entiy.Users;
import Smallprogram.servict.UsersServlet;
import Smallprogram.servict.impl.UsersServletImpl;
import com.alibaba.fastjson.JSON;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet(name = "UsersSelectServlet", value = "/UsersSelectServlet")
public class UsersSelectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        UsersServletImpl ime=new UsersServletImpl();
        List<Users> list=ime.selectusers();
        PrintWriter out=response.getWriter();
        String listid= JSON.toJSONString(list);
        if (list!=null){
            out.print(listid);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
